package com.axzhengxin.platform.business.controller;

import com.axzhengxin.platform.business.domain.BizApplyInfo;
import com.axzhengxin.platform.business.domain.BizLoanInfo;
import com.axzhengxin.platform.business.domain.BizRepaymentInfo;
import com.axzhengxin.platform.business.service.IBizLoanInfoService;
import com.axzhengxin.platform.business.service.IBizRepaymentInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.file.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Author ahzj0005
 * @Date 2021/2/23-15:35
 * 授信流程Controller
 **/
@RestController
@RequestMapping("/business/bizLoanInfo")
public class BizLoanInfoController extends BaseController {

    @Autowired
    private IBizLoanInfoService bizLoanInfoService;

    @Autowired
    private IBizRepaymentInfoService bizRepaymentInfoService;
    /**
     * 待放款订单列表查询
     * @param applyInfo 需求对象
     * @return 分页数据
     */
    @PreAuthorize("@ss.hasPermi('business:bizLoanInfo:list')")
    @RequestMapping("/list")
    public TableDataInfo list(BizApplyInfo applyInfo) {
        startPage();
        List<BizApplyInfo> list = bizLoanInfoService.list(applyInfo);
        return getDataTable(list);
    }

    /**
     * 新增放款
     * @param bizLoanInfo 放款domain
     * @return 处理结果
     */
    @PreAuthorize("@ss.hasPermi('business:bizLoanInfo:insertLoanInfo')")
    @RequestMapping("/insertLoanInfo")
    public AjaxResult insertLoanInfo(BizLoanInfo bizLoanInfo) {
        return bizLoanInfoService.insertLoanInfo(bizLoanInfo);
    }

    /**
     * 新增还款
     * @param bizRepaymentInfo 还款domain
     * @return 处理结果
     */
    @PreAuthorize("@ss.hasPermi('business:bizLoanInfo:insertRepaymentInfo')")
    @RequestMapping("/insertRepaymentInfo")
    public AjaxResult insertRepaymentInfo(BizRepaymentInfo bizRepaymentInfo) {

        return bizLoanInfoService.insertRepaymentInfoVo(bizRepaymentInfo);
    }

    /**
     * 放款信息
     * @return 处理结果
     */
    @PreAuthorize("@ss.hasPermi('business:bizLoanInfo:bizLoanInfoList')")
    @RequestMapping("/bizLoanInfoList")
    public List<BizLoanInfo> bizLoanInfoList(String reqId) {

       return   bizLoanInfoService.bizLoanInfoList(reqId);
    }


    /**
     * 放款信息
     * @return 处理结果
     */
    @PreAuthorize("@ss.hasPermi('business:bizLoanInfo:bizRepaymentInfoList')")
    @RequestMapping("/bizRepaymentInfoList")
    public List<BizRepaymentInfo> bizRepaymentInfoList(String reqId) {

        return   bizRepaymentInfoService.bizRepaymentInfoList(reqId);
    }


    /**
     * 新增还款时 回填放款信息
     * @return 处理结果
     */
    /*@PreAuthorize("@ss.hasPermi('business:bizLoanInfo:getLoanInfo')")*/
    @RequestMapping("/getLoanInfo")
    public BizLoanInfo getLoanInfo(String loanId) {

        return   bizLoanInfoService.getLoanInfo(loanId);
    }

}
